package main

import "fmt"

type xx interface {
}

func show(c interface{}) {
	fmt.Printf("%T, %v/n", c, c)
}

// interface: 代表关键字
// interface{}：代表空接口
func main() {
	var m1 map[string]interface{}
	m1 = make(map[string]interface{}, 16)
	m1["name"] = "tom"
	m1["age"] = 9000
	m1["merried"] = true
	m1["hobby"] = [...]string{"唱", "跳", "rap"}
	fmt.Println(m1)
	show(m1)
	show(false)
	show(nil)

	assign(1000)
	assign("1000")
	assign(true)
}

// 类型断言

// 我想知道空接口值具体类型

func assign(a interface{}) {
	//str, ok := a.(string)
	//if !ok {
	//	fmt.Println("错误")
	//} else {
	//	fmt.Println("字符串", str)
	//	fmt.Printf("%T, %v/n", a, a)
	//}

	switch a.(type) {
	case string:
		fmt.Println("字符串", a)
		fmt.Printf("%T, %v/n", a, a)
	case int:
		fmt.Println("int", a.(int))
	case bool:
		fmt.Println("int", a.(bool))
	}
}
